﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;

public partial class Products : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateControls();
        }
    }
    private void PopulateControls()
    {
        string prodId = Request.QueryString["ProductID"];
        Product data = Product.Single(prodId);
        if (data != null)
        {
            lblName.Text = data.Name;
            lblDes.Text = HttpUtility.HtmlEncode(data.Description);
            lblPrice.Text = string.Format("{0:c}", data.Price);
            prodImage.ImageUrl = Link.ToProductImage(data.Image);
            lnkAddToCart.NavigateUrl = Link.ToAddToCart(prodId);
        }
    }
}